package com.pospi.pospihold.http;


import android.content.Context;

import com.pospi.pospihold.dao.OrderDao;
import com.pospi.pospihold.dto.OrderDto;
import com.pospi.pospihold.util.GetData;

import java.util.List;


/**
 * Created by Qiyan on 2016/5/20.
 * <p>
 * 得到当前可以用的最大的订单号
 */
public class MaxNO {

    public static int getMaxNo(Context context) {
        int maxNo;
        List<OrderDto> orderDtos = new OrderDao(context).findMaxNO(GetData.getYYMMDDTime());
        if (orderDtos.size() == 0) {
            maxNo = Integer.parseInt(GetData.getYYMMDDNoSpellingTime() + "0001");
        } else {
            maxNo = orderDtos.get(orderDtos.size() - 1).getMaxNo() + 1;
        }

        return maxNo;
    }
}